package com.igeek.javase.relation.shopping;

/**
 * @author chenmin
 * 2023/7/13 20:10
 * @description TODO
 */

/*一.订单和货物，用户：
  1.一个订单会有几个货物（一对多的关系）,订单中一个方法（查看商品详情信息）
  2.货物是订单的属性
  3.订单与用户之间的关系，用户类中有下单的方法（用户姓名和订单号）
  4.测试类（调用执行下单方法和查看商品详情信息的方法）
  备注：用户User、订单Order、货物Goods
*/

public class User {

    private String name;
    private String phoneNumber;
    private String address;

    private Order[] orders;

    public <Orders> void xiaDan(){
        System.out.println("用户姓名："+name);
        System.out.println("用户地址："+address);
        System.out.println("用户手机号："+phoneNumber);

        System.out.println("============订单信息===========");
        if(orders!=null){
            //foreach迭代  for(元素类型 临时变量名 : 数组名){}
            for (Order order : orders) {
                if(order!=null){
                    System.out.println("订单编号："+this.getOrders());
                }
            }
        }
    }


    public User() {
        }
    public User(String name, String phoneNumber, String address) {
            this.name = name;
            this.phoneNumber = phoneNumber;
            this.address = address;
        }

    public User(String name, String phoneNumber, String address, Order[]orders){
            this.name = name;
            this.phoneNumber = phoneNumber;
            this.address = address;
            this.orders = orders;
        }


        public String getName () {
            return name;
        }

        public void setName (String name){
            this.name = name;
        }

        public String getPhoneNumber () {
            return phoneNumber;
        }

        public void setPhoneNumber (String phoneNumber){
            this.phoneNumber = phoneNumber;
        }

        public String getAddress () {
            return address;
        }

        public void setAddress (String address){
            this.address = address;
        }

        public Order[] getOrders () {
            return orders;
        }

        public void setOrders (Order[]orders){
            this.orders = orders;
        }



}